package com.googlecode.bpmcenter.model;
 
import java.math.BigDecimal;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
 
@Entity
@Table(name="BPM_ORDER_ITEM")
public class OrderItem {
 
    private Long id;
    private Order order;
    private Long number;
    private Status status;
    private List<File> files;
    private String reference;
    private String description;
    private BigDecimal quantity;
    private String comments;
    private String colors;
    private String sizes;
 
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }
 
    public void setId(Long id) {
        this.id = id;
    }
 
  	@ManyToOne(targetEntity = Order.class, fetch = FetchType.EAGER)
  	@JoinColumn(name = "ORDER_ID")
		public Order getOrder() {
    	return order;
    }

		public void setOrder(Order order) {
    	this.order = order;
    }

		@ManyToOne(fetch = FetchType.EAGER)
		@JoinColumn(name = "STATUS_ID")
		public Status getStatus() {
    	return status;
    }

		public void setStatus(Status status) {
    	this.status = status;
    }

		@Column(name = "COMMENTS")
		public String getComments() {
    	return comments;
    }

		public void setComments(String comments) {
    	this.comments = comments;
    }

		@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
		@JoinTable(name = "ORDER_ITEM_FILES", 
				joinColumns = { 
					@JoinColumn(name = "ORDER_ITEM_ID", nullable = false, updatable = false) }, 
				inverseJoinColumns = { 
					@JoinColumn(name = "FILE_ID", nullable = false, updatable = false) })
		public List<File> getFiles() {
    	return files;
    }

		public void setFiles(List<File> files) {
    	this.files = files;
    }

		@Column(name = "REFERENCE")
		public String getReference() {
    	return reference;
    }

		public void setReference(String reference) {
    	this.reference = reference;
    }

		@Column(name = "DESCRIPTION")
		public String getDescription() {
    	return description;
    }

		public void setDescription(String description) {
    	this.description = description;
    }

		@Column(name = "QUANTITY")
		public BigDecimal getQuantity() {
    	return quantity;
    }

		public void setQuantity(BigDecimal quantity) {
    	this.quantity = quantity;
    }

		@Column(name = "COLORS")
		public String getColors() {
    	return colors;
    }

		public void setColors(String colors) {
    	this.colors = colors;
    }

		@Column(name = "SIZES")
		public String getSizes() {
    	return sizes;
    }

		public void setSizes(String sizes) {
    	this.sizes = sizes;
    }

		@Column(name = "NUMBER")
		public Long getNumber() {
    	return number;
    }

		public void setNumber(Long number) {
    	this.number = number;
    }
		
    @Override
    public String toString() {
        StringBuffer strBuff = new StringBuffer();
        strBuff.append("id : ").append(getId());
        return strBuff.toString();
    }

}